use thiserror::Error;
use tokio::sync::{mpsc, oneshot};
use warp::{reject::Reject, Rejection};

#[derive(Debug, Error)]
pub enum Error {
    #[error("channel send or recevice error")]
    ChannelError,
}

impl From<oneshot::error::RecvError> for Error {
    fn from(_: oneshot::error::RecvError) -> Self {
        Self::ChannelError
    }
}
impl From<mpsc::error::RecvError> for Error {
    fn from(_: mpsc::error::RecvError) -> Self {
        Self::ChannelError
    }
}
impl<T> From<mpsc::error::SendError<T>> for Error {
    fn from(_: mpsc::error::SendError<T>) -> Self {
        Self::ChannelError
    }
}

pub type Result<T> = std::result::Result<T, Rejection>;

impl Reject for Error {}
